package com.daodway.designpattern.statepattern;

import java.awt.Point;

public class EnterMineAndDigForNugget extends State<Miner> {
	private EnterMineAndDigForNugget(){}
	private static EnterMineAndDigForNugget instance=null;
	public static EnterMineAndDigForNugget Instance(){
		if(instance==null){
			instance=new EnterMineAndDigForNugget();
		}
		return instance;
	}
	@Override
	public void Enter(Miner t) {
		Point glodPoint=new Point(50,100);
		if((t.Location().getX()!=glodPoint.getX())&&(t.Location().getY()!=glodPoint.getY())){
			System.out.println(t.entityName+":"+"walkin to the gold mine!");
			t.ChangeLocation(glodPoint);
		}
		
	}

	@Override
	public void Execute(Miner t) {
		// TODO Auto-generated method stub
		//收集金子,增加疲惫度.
		t.AddToGoldCarried(1);
		t.IncreaseFatgue();
		System.out.println(t.entityName+":"+"Pickin up a nugget");
		//如果收集的金子满了,到银行存起来
		if(t.PocketFull()){
			t.ChangeState(VisitBankAndDepositGold.Instance());
		}
		//如果口渴了,到酒吧去喝酒解渴;
		if(t.isThirsty()){
			t.ChangeState(QuenchThirst.instance());
		}
		
	}

	@Override
	public void Exit(Miner t) {
		System.out.println(t.entityName+":"+"Ah I'm leaving the gold mine with mah pockets full o sweet gold");
	}
	@Override
	public boolean OnMessage(Miner t, Telegram msg) {
		// TODO Auto-generated method stub
		return false;
	}
	
	

}
